package com.cjm.one.order.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.order.entity.OrderLog;
import com.cjm.one.order.service.OrderLogService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Tag(name = "后台订单信息")
@RequestMapping("/admin/order/log")
public class OrderLogController {
    @Resource
    private OrderLogService orderLogService;

    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody OrderLog orderLog) {
        log.info("添加订单日志");

      return   Result.ok(orderLogService.addOrderLog(orderLog));
    }
    @GetMapping("/list")
    public Result<Page<OrderLog>> list(@RequestParam(defaultValue = "1") Integer current,
                                       @RequestParam(defaultValue = "10") Integer size) {
        log.info("查询订单日志");

      return  Result.ok(orderLogService.listOrderLogPage(current, size));
    }
    @GetMapping("/all")
    public Result<List<OrderLog>> all(@RequestParam("orderId") Long orderId){
        log.info("查询订单日志");
      return  Result.ok(orderLogService.listOrderLog(orderId));
    }
}
